Re: [SQL] Week of year function?
От | Herouth Maoz |
---|---|
Тема | Re: [SQL] Week of year function? |
Дата | |
Msg-id | l03130300b43b2e7ab424@[147.233.159.109] обсуждение исходный текст |
Ответ на | Re: [SQL] Week of year function? (Herouth Maoz <herouth@oumail.openu.ac.il>) |
Список | pgsql-sql |
At 20:24 +0200 on 25/10/1999, Zot O'Connor wrote: > Herouth Maoz wrote: > > > > At 21:52 +0200 on 22/10/1999, Zot O'Connor wrote: > > > > > Is there a function to return the week of the year (0-51)? > > > > Seems you only need to divide the day of the year by seven to reach that, > > don't you? > > > > BTW I ought to offset the year to some standard too since Jan1 is not a > sunday. I know Intel starts work week 1 in dec this work year. That's why I asked whether you only needed to divide by seven. It depends on your definition of "a week". If you define a week as "seven consecutive days", then in a year with 365 or 366 days you will always have 53 weeks, the last of which being a short one. If you define a week as "Monday to Sunday", or "Sunday to Saturday" (this is culture-dependent), then you may even have 54 weeks per year (52 full weeks, a weekend in the beginning, and the beginning of a week in the end - but only in a leap year). This complicates the calculation a bit. You probably have to subtract the day-of-week (0-7) oy January first from it, and then subtract the resulting date from your $1, and divide by 7. This is true in places where the week's first day is Sunday. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma
В списке pgsql-sql по дате отправления: